package com.cyj.dream.file.model;

import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.annotation.Version;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.cyj.dream.core.constant.Constant;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

import javax.persistence.*;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * @Description: 数据源表
 * @BelongsProject: DreamChardonnay
 * @BelongsPackage: com.cyj.dream.file.model
 * @Author: ChenYongJia
 * @CreateTime: 2021-09-26 14:19
 * @Email: chen87647213@163.com
 * @Version: 1.0
 */
@Data
@Entity
@ToString
@Table(name = "gen_datasource_conf")
@TableName(value = "gen_datasource_conf")
@ApiModel(value = "GenDatasourceConf", description = "数据源表对象")
public class GenDatasourceConf extends Model<GenDatasourceConf> implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 主键--自动增长列
     */
    @Id
    @TableId(value = "id", type = IdType.AUTO)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(nullable = false, columnDefinition = "bigint(20) unsigned COMMENT '数据源表id主键--自增'")
    private Integer id;

    /**
     * 名称--数据库名称
     */
    @Column(columnDefinition = "varchar(64) COMMENT '名称--数据库名称'")
    private String name;

    /**
     * jdbcurl 形如：jdbc:mysql://localhost:3306
     */
    @Column(columnDefinition = "varchar(255) COMMENT 'jdbcurl 形如：jdbc:mysql://localhost:3306'")
    private String url;

    /**
     * 用户名
     */
    @Column(columnDefinition = "varchar(64) COMMENT '用户名'")
    private String username;

    /**
     * 密码
     */
    @Column(columnDefinition = "varchar(128) COMMENT '密码'")
    private String password;

    /**
     * 创建时间
     */
    @TableField(fill = FieldFill.INSERT, insertStrategy = FieldStrategy.NEVER)
    @Column(name = "create_time", nullable = false, columnDefinition = "DATETIME(6) COMMENT '创建时间'")
    private LocalDateTime createTime;

    /**
     * 更新
     */
    @TableField(fill = FieldFill.UPDATE, updateStrategy = FieldStrategy.NEVER)
    @Column(name = "update_time", nullable = false, columnDefinition = "DATETIME(6) COMMENT '修改时间'")
    private LocalDateTime updateTime;

    /**
     * 乐观锁字段
     */
    @Version
    @Column(nullable = false, columnDefinition = "INT COMMENT '版本' default 1")
    private Integer version;

    /**
     * 删除标识符--是否进行select查询
     */
    @TableField(select = true)
    @TableLogic(value = Constant.DELETE_STATUS_UNDELETED, delval = Constant.DELETE_STATUS_DELETED)
    @Column(nullable = false, columnDefinition = "INT COMMENT '逻辑删除标识(0.未删除,1.已删除)' default 0")
    private Integer delFlag;

}
